package dao;

import domain.EntityPerson;
import domain.VirtualFile;
import domain.VirtualUser;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

public interface UserDao {


    @Select("select psword from user where uname = #{username}")
    String getPsword(String username);

    @Select("select * from user where uname = #{username}")
    String haveUser(String username);

    @Select("select * from user where email = #{email}")
    String haveEmail(String email);

    @Insert("insert into user values (null,#{uname},#{psword},#{state},#{create_date_time},#{email})")
    void addUser(VirtualUser virtualUser);

    @Select("select * from user where uname = #{username}")
    VirtualUser getByname(String username);

    @Select("select * from user where uid = #{uid}")
    VirtualUser getByuid(int uid);

    @Update("UPDATE user SET uname = #{uname}, email = #{email} WHERE uid = #{uid}")
    void resetUserInfo(@Param("uid") int uid, @Param("uname") String uname, @Param("email") String email);

    @Select("select *from user")
    ArrayList<VirtualUser> getAllusers();

    @Update("UPDATE user set uname = #{uname},email = #{email},state = #{state} where uid = #{uid}")
    void updateUser(VirtualUser user);

    @Delete("delete from user where uid = #{uid}")
    void deleteUser(@Param("uid")int uid);

    @Select("select * from file where uploader = #{uid}")
    ArrayList<VirtualFile> getUploadHistroyByUid(@Param("uid") int uid);
}
